#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll rr() {
    ll s = 0, w = false, c = getchar();
    for (; !isdigit(c); c = getchar())
        w = w || c == '-';
    for (; isdigit(c); c = getchar())
        s = s * 10 + c - '0';
    return w ? -s : s;
}

// END OF HEADER

const int M = 2e5 + 7;

struct Node {
    int l, r;
    ll val, lazy;
} tr[M * 4];

struct pii {
    int x, y;
    bool operator<(pii &o) const {
        if (y == o.y)
            return x > o.x;
        return y < o.y;
    }
} seg[M];

int w[M];

#define ul (u * 2)
#define ur (u * 2 + 1)

void pushdown(int u) {
    ll lazy = tr[u].lazy;
    if (lazy) {
        tr[ul].val += lazy;
        tr[ul].lazy += lazy;
        tr[ur].val += lazy;
        tr[ur].lazy += lazy;
    }
}

void pushup(int u) {
    tr[u].val = min(tr[ul].val, tr[ur].val);
}

void build(int u, int l, int r) {
    if (l == r) {
        tr[u] = {l, r, w[l]};
        return;
    }
    tr[u] = {l, r};
    int mid = (l + r) / 2;
    build(ul, l, mid), build(ur, mid + 1, r);
    pushup(u);
}

ll query(int u, int l, int r) {
    if (tr[u].l >= l && tr[u].r <= r)
        return tr[u].val;
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) / 2;
    ll ans = 0x3f3f3f3f3f3f3f3f;
    if (l <= mid)
        ans = min(ans, query(ul, l, r));
    if (r > mid)
        ans = min(ans, query(ur, l, r));
    return ans;
}

void modify(int u, int l, int r, ll x) {
    if (tr[u].l >= l && tr[u].r <= r) {
        tr[u].val += x;
        tr[u].lazy += x;
        return;
    }
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) / 2;
    if (l <= mid)
        modify(ul, l, r, x);
    if (r > mid)
        modify(ur, l, r, x);
    pushup(u);
}

int main() {
    int n = rr(), m = rr();

    for (int i = 1; i < n; i++)
        w[i] = rr();
    build(1, 1, n - 1);

    for (int i = 0; i < m; i++) {
        int x = rr(), y = rr();
        if (x > y)
            swap(x, y);
        seg[i] = {x, y};
    }
    sort(seg, seg + m);

    ll ans = 0;
    for (int i = 0; i < m; i++) {
        ll data = query(1, seg[i].x + 1, seg[i].y);
        ans += data;
        modify(1, seg[i].x + 1, seg[i].y, -data);
    }
    printf("%lld", ans);
    return 0;
}